using com.youzu.warh.protocol;
using CustomDataStruct;
using ProtoBuf.Serializers;

namespace battle
{
    public class SCRoundFightDecorator: ICustomProtoSerializer
    {
        public void SetValue(object target, object value, int fieldNumber)
        {
            SCRoundFight data = target as SCRoundFight;
            if (data == null)
            {
                return;
            }

            switch (fieldNumber)
            {
                case 1:
                    data.fightInfo.Add((TroopFightInfo)value);
                    break;
                case 2:
                    data.skills.Add((CastAreaSkill)value);
                    break;
                case 3:
                    data.fightFrame = ValueObject.Value<long>(value);
                    break;
                case 4:
                    data.fightFrameTime =  ValueObject.Value<long>(value);
                    break;
                case 5:
                    data.siegeFightInfo.Add((SiegeFightInfo)value);
                    break;
                case 6:
                    data.scene = (RtsScenes)value;
                    break;
                case 7:
                    data.happenWorldId = ValueObject.Value<long>(value);
                    break;
            }
        }

        public object GetValue(object target, int fieldNumber)
        {
            SCRoundFight data = target as SCRoundFight;
            if (data == null)
            {
                return null;
            }

            switch (fieldNumber)
            {
                case 1:
                    return data.fightInfo;
                case 2:
                    return data.skills;
                case 3:
                    return ValueObject.Get(data.fightFrame);
                case 4:
                    return ValueObject.Get(data.fightFrameTime);
                case 5:
                    return data.siegeFightInfo;
                case 6:
                    return data.scene;
                case 7:
                    return data.happenWorldId;
            }

            return null;
        }
    }
}